<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .login{
            width: 400px;
            height: 400px; 
            background: #fff;
            margin: 100px auto;
            padding: 10px;
            border: 2px solid #ff8000;
        }
        h2{
            text-align: center;
            border-bottom: 1px solid #ff8000;
            padding-bottom: 10px;
            color: #ff8000;
        }
        #inp,#inp2{
            outline: none;
            border: 1px solid #ccc;
            display: block;
            margin: 26px auto;
            width: 300px;
            height: 40px;
            padding: 10px;
            box-sizing: border-box;
            font-size: 16px;
            text-indent: 6px;
        }
        [type="button"]{
            width: 50px;
            height: 30px;
        }
        a{
            display: block;
            width: 300px;
            height: 40px;
            background: #ff8000;
            text-align: center;
            line-height: 40px;
            font-size: 20px;
            font-weight: bold;
            margin: 30px auto;
            color: white;
        }
    </style>
</head>
<body>
    <form class="login">
        <h2>账户注册</h2>
        <input type="text" id="inp" placeholder="请输入用户名">
        <input type="password" id="inp2" placeholder="请输入密码">
        <a href="" id="go">注册</a>
    </form>
    <script src="../lib/jquery-1.12.4.min.js"></script>
    <script>
        $('#go').on('click',function(){
            return false;
        })
        $('#go').on('click',function(){
            var inpName = $('#inp').val();
            var inpPassword = $('#inp2').val();
            $.ajax({
                url:"http://localhost/suning/src/interface/02.php", // 请求地址，必填
                type:"POST", // 请求方式(GET,POST,..)默认是GET
                data:{
                    un:inpName,
                    pw:inpPassword,
                }, // 携带到后端的参数
                dataType:"json", 
                success:function(res){
                    if(res===1){
                        alert('注册成功,点击跳往登录页面');
                        location.href = 'http://localhost/suning/src/pages/denglu.html'
                    }
                }, // 成功的回调
            })
        })
    </script>
</body>
</html>